package com.benny_driving.act;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.benny_driving.R;

public class StartAct extends BaseAct implements OnClickListener {
	private TextView image = null;
	private int num = 0;
	private Handler handler = null;
	Intent i = new Intent();
	private Runnable r = new Runnable() {

		@Override
		public void run() {
			if (num < 5) {
				num++;
				System.out.println(num);
				handler.postDelayed(r, 1000);
			} else {
				Intent i = new Intent();
				i.setClass(StartAct.this, MainAct.class);
				startActivity(i);
				handler.removeCallbacks(r);
				StartAct.this.finish();
			}
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.act_start);
		initView();
		handler = new Handler();
		handler.post(r);
	}

	private void initView() {
		image = (TextView) findViewById(R.id.start_tv_Start);
		image.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		Intent i = new Intent();
		i.setClass(StartAct.this, MainAct.class);
		startActivity(i);
		handler.removeCallbacks(r);
		StartAct.this.finish();
	}
}
